<?php
/*<<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>> BD CLASS <<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>>
						BD CLASS PARA EL "M�DULO DE EXPEDIENTES ELECTR�NICOS
                        		 PARA PYMES EN EL SISTEMA SIR-ZEE"
                         
                      		  ELABORADO POR:
                              			SAYRE ANDREA CASTO Z��IGA
                              			MARIANELA FONSECA GONZ�LEZ
                              			MARLEN TREVI�O VILLALOBOS
                         
                         		CURSO PROYECTO - I SEMESTRE 2005

<<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>>*/

class db_class 
{
    var $db, $conn, $result, $rows, $data, $a_rows;
    var $user, $pass, $host;

   	/*FUNCION PARA REALIZAR LA CONEXION A LA BASE DE DATOS*/
	function Connect()
	{
		$this->conn = pg_connect("
		                          host=  localhost
		                          port=    5432 
		                          password= pymes
							      user=     admin 
							      dbname=  sirzeedb
								  ")
       or die ("Unable to connect to Postgres Server" . pg_last_error($conn));	
	}

	/*FUNCION PARA EFECTUAR LA DESCONEXION A UNA BASE DE DATOS DETERMINADA*/
    function Disconnect() 
	{
    	@pg_close($this->conn);
	}
	
   	/*CONSULTA A LA BASE DE DATOS, QUE DEVUELVE UN SOLO ELEMENTO DE LA BASE DE DATOS*/
    function QueryItem ($query) 
	{
        $this->result = @pg_query($this->conn, $query) or
            			 pg_result_error("No se puede realizar la consulta: $query");
        $this->rows = @pg_num_rows($this->result);
        $this->a_rows = @pg_affected_rows($this->id);
        $this->data = @pg_fetch_array($this->result);
	
        return($this->data[0]);
		
    }
	
	/*CONSULTA QUE DEVUELVE VARIOS ELEMENTOS DE LA BASE DE DATOS*/
	function Query ($query) 
	{
        $this->result = @pg_query($this->conn, $query) or
            			 pg_result_error ("No se puede realizar la consulta: $query");
        $this->rows = @pg_num_rows($this->result);
        $this->a_rows = @pg_affected_rows($this->result);
    }
	
	/*FUNCION PARA RECORRER UNA CONSULTA, REALIZADA A LA BASE DE DATOS*/
    function Fetch ($row) 
	{
        @pg_lo_seek($this->result, $row) or
         pg_result_error("Unable to seek data row: $row");
        $this->data = @pg_fetch_array($this->result) or
            		   pg_result_error("Unable to fetch row: $row");
    }	
}

?>
